home *** CD-ROM | disk | FTP | other *** search
- #import <stdio.h>
- #import <stdlib.h>
- #import <streams/streams.h>
- #import <appkit/graphics.h>
- #import <appkit/NXBitmapImageRep.h>
- #import "NXBitmapImageRepControl.h"
- #import "ImageControl.h"
- #import "pcx.h"
- #import "pcxlib.h"
-
- @implementation PCX
-
- - init
- {
- return self;
- }
-
- - free
- {
- return [super free];
- }
-
- - readFromStream: (NXStream *)stream from: sender;
- {
- return pcxread(stream);
- }
-
- - (BOOL)write: (id)image toStream: (NXStream *)stream from: sender;
- {
- id imageCon = [sender getImageControl: image];
- unsigned char *data, r[256], g[256], b[256];
-
- [imageCon convertToPalette: 256
- andReturn: &data
- andPalettes: r:g:b];
-
- pcxwrite(stream,
- data, r, g, b,
- [image pixelsWide],
- [image pixelsHigh],
- 256);
-
- free(data);
-
- return YES;
- }
-
- - readAllFromStream: (NXStream *)stream from: sender
- {
- return nil;
- }
-
- - (BOOL)writeAll: (id)image toStream: (NXStream *)stream
- {
- return NO;
- }
-
- - customSaveView: (int)width
- {
- return nil;
- }
-
- - customOpenView: (int)width
- {
- return nil;
- }
-
- - (char *)getFormatName
- {
- return("PCX - A IBM/PC Picture Format");
- }
-
- - (BOOL)setCustomParameter: (const char *)parameter withValue: (void *)ptr
- {
- return NO;
- }
-
- - (void *)getCustomParameter: (const char *)parameter
- {
- return NULL;
- }
-
- - (char *)copyrightNotice
- {
- return "Original PCX Code\nCopyright (c) 1990 by Michael Davidson\n\nConverter Wrapper\nCopyright (c) 1993 by Alex Raftis.";
- }
-
- - (int)errorState
- {
- return CONVERT_ERR_NONE;
- }
-
- - (int)errorMessage
- {
- return ERROR_NO_ERROR;
- }
-
- - (char *)errorStringMessage
- {
- return NULL;
- }
-
- - (BOOL)needsWindowServer;
- {
- return NO;
- }
-
- - (char *)protocolVersion
- {
- return "1.0";
- }
-
- @end
-